package com.springboot.aop.config;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;


public class AopAroundConfig {

    private Logger logger = LoggerFactory.getLogger(AopAroundConfig.class);

    /**
     * 定义切入点，切入点为com.example.demo.aop.AopController中的所有函数,通过@Pointcut注解声明频繁使用的切点表达式
     */
    @Pointcut("execution(public * com.springboot.aop.controller.AopController.*(..)))")
    public void BrokerAspect(){
    }

    @Around("BrokerAspect()")
    public void around(ProceedingJoinPoint pjp) throws Throwable {
        try{
            logger.info("Before");
            pjp.proceed();
            logger.info("After ");
        } catch (Throwable throwable){
            logger.info("异常通知");
        }

    }
}
